// Copyright  2004-2008 Backplane Ltd.
//
// This file is part of Ubiquity formsPlayer
//
// Ubiquity formsPlayer is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3 of the License, or (at your
// option) any later version.
//
// Ubiquity formsPlayer is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License
// along with Ubiquity formsPlayer If not, see <http://www.gnu.org/licenses/>.
//	
//
//   Purpose: declaration of CDocumentLS.
//   $Id$



// DOM3ASLS.h: interface for the CDOMInputSource class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_DOM3ASLS_H__B7431FD0_18A3_4F5D_BE24_9B21F1A59A59__INCLUDED_)
#define AFX_DOM3ASLS_H__B7431FD0_18A3_4F5D_BE24_9B21F1A59A59__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "DOM3Core.h"

class CDOMBuilder;
class CDOMWriter;
class CDOMInputSource;
//class CDOMEntityResolver;
//class CDOMBuilderFilter;

class CDOMImplementationLS {
public:
	CDOMImplementationLS();
	virtual ~CDOMImplementationLS();

	enum EDOMImplementationLSMode
	{
		MODE_SYNCHRONOUS = 1,
		MODE_ASYNCHRONOUS = 2
	};

	CDOMBuilder* createDOMBuilder(CDOMImplementationLS::EDOMImplementationLSMode eMode);
	CDOMWriter* createDOMWriter();
	CDOMInputSource* createDOMInputSource();
};

class CDOMBuilder {
public:
	CDOMBuilder(CDOMImplementationLS::EDOMImplementationLSMode eMode);
	virtual ~CDOMBuilder();

	enum EActionTypes
	{
		ACTION_REPLACE = 1,
		ACTION_APPEND = 2,
		ACTION_INSERT_AFTER = 3,
		ACTION_INSERT_BEFORE = 4
	};

	void setFeature(CDOMString pName, VARIANT_BOOL bState);
	VARIANT_BOOL canSetFeature(CDOMString pName, VARIANT_BOOL bState);
	VARIANT_BOOL getFeature(CDOMString pName);
	CDOM3Document* parseURI(CDOMString pUri);
	CDOM3Document* parse(CDOMInputSource* pIs);
	void parseWithContext(CDOMInputSource* pIs, IXMLDOMNode* pCnode, EActionTypes eAction);

private:
	//CDOMEntityResolver* m_pEntityResolver;
	//CDOMErrorHandler* m_pErrorHandler;
	//CDOMBuilderFilter* m_pFilter;
	CDOMImplementationLS::EDOMImplementationLSMode m_eMode;
};

class CDOMReader {
public:
	CDOMReader() {}
	virtual ~CDOMReader() {}
};

class CDocumentLS : public CDOM3Document {
public:
	CDocumentLS();
	virtual ~CDocumentLS();

	void abort();
	BOOL load(CDOMString pUri);
	BOOL loadXML(CDOMString pSource);
	CDOMString* saveXML(IXMLDOMNode* pSnode);

//[TODO] Protect this with a method
//private:
	BOOL m_bAsync;
};

class CDOMInputSource  
{
public:
	CDOMInputSource();
	virtual ~CDOMInputSource();

	BOOL read(CDocumentLS* pDocument);
	//[TODO] These should be private, and then get_xxx and put_xxx
//private:
	CDOMInputSource* m_pByteStream;
	CDOMReader* m_pCharacterStream;
	CComBSTR m_sStringData;
	CComBSTR m_sEncoding;
	CComBSTR m_sPublicId;
	CComBSTR m_sSystemId;
	CComBSTR m_sBaseURI;
};

class CDOMWriter {
public:
	CDOMWriter() { }
	virtual ~CDOMWriter() { }

	/*
void               setFeature(in DOMString name, 
in boolean state)
raises(dom::DOMException);
boolean            canSetFeature(in DOMString name, 
in boolean state);
boolean            getFeature(in DOMString name)
raises(dom::DOMException);
attribute DOMString       encoding;
readonly attribute DOMString       lastEncoding;
attribute DOMString       newLine;
attribute DOMErrorHandler errorHandler;
boolean            writeNode(in DOMOutputStream destination, 
in Node wnode)
raises(dom::DOMSystemException);
DOMString          writeToString(in Node wnode)
raises(dom::DOMException);
*/
};


#endif // !defined(AFX_DOM3ASLS_H__B7431FD0_18A3_4F5D_BE24_9B21F1A59A59__INCLUDED_)

/*

  typedef dom::DOMErrorHandler DOMErrorHandler;
  typedef dom::DOMString DOMString;
  typedef dom::Node Node;
  typedef dom::Document Document;
  typedef dom::DOMOutputStream DOMOutputStream;
  typedef dom::DOMReader DOMReader;
  typedef dom::DOMError DOMError;

  interface DOMBuilder;
  interface DOMWriter;
  interface DOMInputSource;
  interface DOMEntityResolver;
  interface DOMBuilderFilter;


  interface DOMEntityResolver {
    DOMInputSource     resolveEntity(in DOMString publicId, 
                                     in DOMString systemId, 
                                     in DOMString baseURI)
                                        raises(dom::DOMSystemException);
  };

  interface DOMBuilderFilter {
    unsigned long      startNode(in Node snode);
    unsigned long      endNode(in Node enode);
    readonly attribute unsigned long   whatToShow;
  };

  interface LSLoadEvent : events::Event {
    readonly attribute Document        newDocument;
    readonly attribute DOMInputSource  inputSource;
  };

  interface LSProgressEvent : events::Event {
    readonly attribute DOMInputSource  inputSource;
    readonly attribute unsigned long   position;
    readonly attribute unsigned long   totalSize;
  };

  interface DOMWriterFilter : traversal::NodeFilter {
    readonly attribute unsigned long   whatToShow;
  };

  interface ParseErrorEvent : events::Event {
    readonly attribute DOMError        error;
  };

*/
